/*
 * @Author: White
 * @description: 
 * @LastEditTime: 2021-06-24 21:37:15
 */
const state = {
    isCollapse: false,  //侧边伸缩栏
    tagFlag: false,  //标签卡
    tabList: [
        {
            path: "/",
            label: "home",
            name: 'home',
            icon: "video-play"
        },
    ]
}

const mutations = {
    selectMenu(state, val) {
        if (val.name !== 'home') {
            let result = state.tabList.findIndex(item => item.name === val.name)
            result === -1 ? state.tabList.push(val) : ''
        }
    },

    // 关闭所有tab标签
    allTab(state) {
        state.tabList = [
            {
                path: "/",
                label: "home",
                name: 'home',
                icon: "video-play"
            },
        ];
    },

    // 关闭单个tab标签
    closeTab(state, val) {
        let result = state.tabList.findIndex(item => item.name === val.name)
        state.tabList.splice(result, 1)
    },

    // 侧边伸缩栏
    collapseMenu(state) {
        state.isCollapse = !state.isCollapse
    },

    // 标签卡
    tagFlag(state) {
        state.tagFlag = !state.tagFlag
    },
    
}

export default {
    state,
    mutations
}